<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, Rank2Types, UnboxedTuples #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Private</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Copyright   : (c) 2011 Bryan O'Sullivan</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Private</span><span>
</span><span id="line-13"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-14"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Private.html#runText"><span class="hs-identifier">runText</span></a></span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Private.html#span_"><span class="hs-identifier">span_</span></a></span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.html#"><span class="hs-identifier">Control.Monad.ST</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier">ST</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier">runST</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.html"><span class="hs-identifier">Data.Text.Internal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier">Text</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#text"><span class="hs-identifier">text</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Unsafe.html"><span class="hs-identifier">Data.Text.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Unsafe.html#Iter"><span class="hs-identifier">Iter</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Unsafe.html#iter"><span class="hs-identifier">iter</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Array.html"><span class="hs-identifier">Data.Text.Array</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">A</span></span><span class="hs-cpp">

#if defined(ASSERTS)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Stack</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HasCallStack</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-27"></span><span class="annot"><a href="Data.Text.Internal.Private.html#span_"><span class="hs-identifier hs-type">span_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-28"></span><span id="span_"><span class="annot"><span class="annottext">span_ :: (Char -&gt; Bool) -&gt; Text -&gt; (# Text, Text #)
</span><a href="Data.Text.Internal.Private.html#span_"><span class="hs-identifier hs-var hs-var">span_</span></a></span></span><span> </span><span id="local-6989586621679107243"><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="#local-6989586621679107243"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679107242"><span class="annot"><span class="annottext">t :: Text
</span><a href="#local-6989586621679107242"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span id="local-6989586621679107240"><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679107240"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span id="local-6989586621679107239"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107239"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679107238"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107238"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679107237"><span class="hs-identifier hs-var">hd</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679107236"><span class="hs-identifier hs-var">tl</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-29"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679107237"><span class="annot"><span class="annottext">hd :: Text
</span><a href="#local-6989586621679107237"><span class="hs-identifier hs-var hs-var">hd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Int -&gt; Text
</span><a href="Data.Text.Internal.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679107240"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107239"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107235"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-30"></span><span>        </span><span id="local-6989586621679107236"><span class="annot"><span class="annottext">tl :: Text
</span><a href="#local-6989586621679107236"><span class="hs-identifier hs-var hs-var">tl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Int -&gt; Text
</span><a href="Data.Text.Internal.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679107240"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107239"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107235"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107238"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107235"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679107235"><span class="annot"><span class="annottext">k :: Int
</span><a href="#local-6989586621679107235"><span class="hs-identifier hs-var hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="#local-6989586621679107230"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-32"></span><span>        </span><span id="local-6989586621679107230"><span class="annot"><span class="annottext">loop :: Int -&gt; Int
</span><a href="#local-6989586621679107230"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679107226"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107226"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107226"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107238"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="#local-6989586621679107243"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679107223"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="#local-6989586621679107230"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107226"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107222"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107226"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-34"></span><span>            </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="Data.Text.Unsafe.html#Iter"><span class="hs-identifier hs-type">Iter</span></a></span><span> </span><span id="local-6989586621679107223"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679107223"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span id="local-6989586621679107222"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107222"><span class="hs-identifier hs-var">d</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -&gt; Int -&gt; Iter
</span><a href="Data.Text.Unsafe.html#iter"><span class="hs-identifier hs-var">iter</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679107242"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107226"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-35"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Private.html#span_"><span class="hs-pragma hs-type">span_</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="annot"><a href="Data.Text.Internal.Private.html#runText"><span class="hs-identifier hs-type">runText</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679107261"><span class="annot"><a href="#local-6989586621679107261"><span class="hs-identifier hs-type">s</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Array.html#MArray"><span class="hs-identifier hs-type">A.MArray</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679107261"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679107261"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679107261"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-42"></span><span id="runText"><span class="annot"><span class="annottext">runText :: (forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text) -&gt; Text
</span><a href="Data.Text.Internal.Private.html#runText"><span class="hs-identifier hs-var hs-var">runText</span></a></span></span><span> </span><span id="local-6989586621679107220"><span class="annot"><span class="annottext">forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text
</span><a href="#local-6989586621679107220"><span class="hs-identifier hs-var">act</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s Text) -&gt; Text
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text
forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text
</span><a href="#local-6989586621679107220"><span class="hs-identifier hs-var">act</span></a></span><span> </span><span class="annot"><span class="annottext">((MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text)
-&gt; (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679107216"><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679107216"><span class="hs-identifier hs-var">marr</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679107215"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107215"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-43"></span><span>                             </span><span id="local-6989586621679107214"><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679107214"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MArray s -&gt; ST s Array
forall s. MArray s -&gt; ST s Array
</span><a href="Data.Text.Array.html#unsafeFreeze"><span class="hs-identifier hs-var">A.unsafeFreeze</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679107216"><span class="hs-identifier hs-var">marr</span></a></span><span>
</span><span id="line-44"></span><span>                             </span><span class="annot"><span class="annottext">Text -&gt; ST s Text
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; ST s Text) -&gt; Text -&gt; ST s Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Int -&gt; Text
</span><a href="Data.Text.Internal.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679107214"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679107215"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Private.html#runText"><span class="hs-pragma hs-type">runText</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-46"></span></pre></body></html>